Code
library(tidyverse)
library(ggplot2)
::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE) knitr
Young Soo Choi
August 24, 2022
Read the data abot organic eggs’ price.
# A tibble: 120 × 5
date xld xlhd ld lhd
<chr> <dbl> <dbl> <dbl> <dbl>
1 Jan 2004 230 132 230 126
2 February 230 134. 226. 128.
3 March 230 137 225 131
4 April 234. 137 225 131
5 May 236 137 225 131
6 June 241 137 231. 134.
7 July 241 137 234. 134.
8 August 241 137 234. 134.
9 September 241 136. 234. 130.
10 October 241 136. 234. 128.
# … with 110 more rows
# ℹ Use `print(n = ...)` to see more rows
I tried various methods, but I still couldn’t find a suitable method to change the year and month into one variable. So instead, I gave each row an order and tidy the data.
# A tibble: 120 × 6
date xld xlhd ld lhd order
<chr> <dbl> <dbl> <dbl> <dbl> <int>
1 Jan 2004 230 132 230 126 1
2 February 230 134. 226. 128. 2
3 March 230 137 225 131 3
4 April 234. 137 225 131 4
5 May 236 137 225 131 5
6 June 241 137 231. 134. 6
7 July 241 137 234. 134. 7
8 August 241 137 234. 134. 8
9 September 241 136. 234. 130. 9
10 October 241 136. 234. 128. 10
# … with 110 more rows
# ℹ Use `print(n = ...)` to see more rows
I drew a scatter plot of extra large dozen and large dozen.
It looks like they have a strong relation.
The relationship between extra large and its half, large and its half, also seems similar.
---
title: "Challenge 7"
author: "Young Soo Choi"
desription: "Visualizing Multiple Dimensions"
date: "08/24/2022"
format:
html:
toc: true
code-fold: true
code-copy: true
code-tools: true
categories:
- challenge_7
---
```{r}
#| label: setup
#| warning: false
#| message: false
library(tidyverse)
library(ggplot2)
knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)
```
## Read in data
Read the data abot organic eggs' price.
```{r}
library(readxl)
eggs <- read_xls("_data/organiceggpoultry.xls",
sheet="Data",
range="B6:F125",
col_names = c("date", "xld", "xlhd", "ld", "lhd"))
eggs
```
## Tidy Data
I tried various methods, but I still couldn't find a suitable method to change the year and month into one variable. So instead, I gave each row an order and tidy the data.
```{r}
eggs<-eggs%>%
mutate(order=1:120)
eggs
```
## Visualization with Multiple Dimensions
I drew a scatter plot of extra large dozen and large dozen.
```{r}
ggplot(data=eggs)+
geom_point(mapping=aes(x=xld, y=ld))+
geom_smooth(mapping=aes(x=xld, y=ld))
```
It looks like they have a strong relation.
The relationship between extra large and its half, large and its half, also seems similar.
```{r}
ggplot(data=eggs)+
geom_point(mapping=aes(x=xld, y=xlhd))+
geom_smooth(mapping=aes(x=xld, y=xlhd))
```
```{r}
ggplot(data=eggs)+
geom_point(mapping=aes(x=ld, y=lhd))+
geom_smooth(mapping=aes(x=ld, y=lhd))
```